<html>
<head><meta charset="utf-8"><title>April Fools notion (not posting as an RFC): `infix_func` · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/April.20Fools.20notion.20(not.20posting.20as.20an.20RFC).3A.20.60infix_func.60.html">April Fools notion (not posting as an RFC): `infix_func`</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="232837449"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/April%20Fools%20notion%20%28not%20posting%20as%20an%20RFC%29%3A%20%60infix_func%60/near/232837449" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/April.20Fools.20notion.20(not.20posting.20as.20an.20RFC).3A.20.60infix_func.60.html#232837449">(Apr 01 2021 at 23:06)</a>:</h4>
<p>After the thread on lexical spaces available for future language extensions, which observed that the backquote is unused, I briefly entertained the idea of an April Fools RFC, proposing the syntax <code> expr `two_argument_function` expr </code> for bespoke infix operators, in the style of Haskell.</p>



<a name="232837541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/April%20Fools%20notion%20%28not%20posting%20as%20an%20RFC%29%3A%20%60infix_func%60/near/232837541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/April.20Fools.20notion.20(not.20posting.20as.20an.20RFC).3A.20.60infix_func.60.html#232837541">(Apr 01 2021 at 23:06)</a>:</h4>
<p>I decided not to post it, for two reasons:</p>
<ul>
<li>People might actually like the proposal, and might be disappointed that it wasn't serious.</li>
<li>Haskell actually uses that syntax, and I didn't want to come across as poking fun at another language. (I actually think that's a cool feature of Haskell, but that might not come across in an RFC context.)</li>
</ul>



<a name="232837623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/April%20Fools%20notion%20%28not%20posting%20as%20an%20RFC%29%3A%20%60infix_func%60/near/232837623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/April.20Fools.20notion.20(not.20posting.20as.20an.20RFC).3A.20.60infix_func.60.html#232837623">(Apr 01 2021 at 23:07)</a>:</h4>
<p>Seemed worth mentioning, though, both for amusement value and as an example of "major features from other languages that we don't have and probably won't".</p>



<a name="232838430"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/April%20Fools%20notion%20%28not%20posting%20as%20an%20RFC%29%3A%20%60infix_func%60/near/232838430" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/April.20Fools.20notion.20(not.20posting.20as.20an.20RFC).3A.20.60infix_func.60.html#232838430">(Apr 01 2021 at 23:16)</a>:</h4>
<p>I recall this being floated around as a requested feature by maths people.</p>



<a name="232838468"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/April%20Fools%20notion%20%28not%20posting%20as%20an%20RFC%29%3A%20%60infix_func%60/near/232838468" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/April.20Fools.20notion.20(not.20posting.20as.20an.20RFC).3A.20.60infix_func.60.html#232838468">(Apr 01 2021 at 23:16)</a>:</h4>
<p>both as this exact proposal as well as some other form of custom operators.</p>



<a name="232838651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/April%20Fools%20notion%20%28not%20posting%20as%20an%20RFC%29%3A%20%60infix_func%60/near/232838651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/April.20Fools.20notion.20(not.20posting.20as.20an.20RFC).3A.20.60infix_func.60.html#232838651">(Apr 01 2021 at 23:19)</a>:</h4>
<p>yeah i would like this lol. but, i also get that it would probably be less than ideal in a lot of cases</p>



<a name="232840478"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/April%20Fools%20notion%20%28not%20posting%20as%20an%20RFC%29%3A%20%60infix_func%60/near/232840478" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/April.20Fools.20notion.20(not.20posting.20as.20an.20RFC).3A.20.60infix_func.60.html#232840478">(Apr 01 2021 at 23:40)</a>:</h4>
<p>Yeah, I can see this being really nice for things like <code>a `dot` b</code>.</p>



<a name="232840512"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/April%20Fools%20notion%20%28not%20posting%20as%20an%20RFC%29%3A%20%60infix_func%60/near/232840512" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/April.20Fools.20notion.20(not.20posting.20as.20an.20RFC).3A.20.60infix_func.60.html#232840512">(Apr 01 2021 at 23:41)</a>:</h4>
<p>I think the big difference between Rust and Haskell for it is that we can already do <code>a.dot(b)</code>, which might be close enough to make an additional way less helpful.</p>



<a name="232874811"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/April%20Fools%20notion%20%28not%20posting%20as%20an%20RFC%29%3A%20%60infix_func%60/near/232874811" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> NeoRaider <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/April.20Fools.20notion.20(not.20posting.20as.20an.20RFC).3A.20.60infix_func.60.html#232874811">(Apr 02 2021 at 08:32)</a>:</h4>
<p>Scala allows omitting the dot and the parentheses for 0-ary and 1-ary method calls, so <code>a dot b</code> would be equivalent to <code>a.dot(b)</code>: <a href="https://docs.scala-lang.org/style/method-invocation.html#symbolic-methodsoperators">https://docs.scala-lang.org/style/method-invocation.html#symbolic-methodsoperators</a></p>
<p>It is only recommended for pure operator-like operations though because the syntax can easily lead to confusion otherwise...</p>



<a name="232876965"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/April%20Fools%20notion%20%28not%20posting%20as%20an%20RFC%29%3A%20%60infix_func%60/near/232876965" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/April.20Fools.20notion.20(not.20posting.20as.20an.20RFC).3A.20.60infix_func.60.html#232876965">(Apr 02 2021 at 09:00)</a>:</h4>
<p>With the prefix reservation project we could also experiment with <code>a op#function_name b</code></p>



<a name="232877048"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/April%20Fools%20notion%20%28not%20posting%20as%20an%20RFC%29%3A%20%60infix_func%60/near/232877048" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/April.20Fools.20notion.20(not.20posting.20as.20an.20RFC).3A.20.60infix_func.60.html#232877048">(Apr 02 2021 at 09:01)</a>:</h4>
<p>Huh, that's fascinating.</p>



<a name="232877053"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/April%20Fools%20notion%20%28not%20posting%20as%20an%20RFC%29%3A%20%60infix_func%60/near/232877053" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/April.20Fools.20notion.20(not.20posting.20as.20an.20RFC).3A.20.60infix_func.60.html#232877053">(Apr 02 2021 at 09:01)</a>:</h4>
<p>Yeah, that would work.</p>



<a name="232878301"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/April%20Fools%20notion%20%28not%20posting%20as%20an%20RFC%29%3A%20%60infix_func%60/near/232878301" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> isHavvy <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/April.20Fools.20notion.20(not.20posting.20as.20an.20RFC).3A.20.60infix_func.60.html#232878301">(Apr 02 2021 at 09:17)</a>:</h4>
<p>Oh no. Scope creep.</p>



<a name="232878391"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/April%20Fools%20notion%20%28not%20posting%20as%20an%20RFC%29%3A%20%60infix_func%60/near/232878391" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> isHavvy <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/April.20Fools.20notion.20(not.20posting.20as.20an.20RFC).3A.20.60infix_func.60.html#232878391">(Apr 02 2021 at 09:18)</a>:</h4>
<p>Who needs <code>k#keyword</code> when you have <code>keyword#</code></p>



<a name="232878632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/April%20Fools%20notion%20%28not%20posting%20as%20an%20RFC%29%3A%20%60infix_func%60/near/232878632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/April.20Fools.20notion.20(not.20posting.20as.20an.20RFC).3A.20.60infix_func.60.html#232878632">(Apr 02 2021 at 09:21)</a>:</h4>
<p>perhaps it should be <code>a op# function_name b</code> then?</p>



<a name="232878773"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/April%20Fools%20notion%20%28not%20posting%20as%20an%20RFC%29%3A%20%60infix_func%60/near/232878773" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> isHavvy <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/April.20Fools.20notion.20(not.20posting.20as.20an.20RFC).3A.20.60infix_func.60.html#232878773">(Apr 02 2021 at 09:23)</a>:</h4>
<p><code>a op#(function_name) b</code> using <code>pub(crate)</code> as precedence. <span aria-label="stuck out tongue" class="emoji emoji-1f61b" role="img" title="stuck out tongue">:stuck_out_tongue:</span></p>



<a name="232878924"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/April%20Fools%20notion%20%28not%20posting%20as%20an%20RFC%29%3A%20%60infix_func%60/near/232878924" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/April.20Fools.20notion.20(not.20posting.20as.20an.20RFC).3A.20.60infix_func.60.html#232878924">(Apr 02 2021 at 09:25)</a>:</h4>
<p><span class="user-mention silent" data-user-id="296643">isHavvy</span> <a href="#narrow/stream/213817-t-lang/topic/April.20Fools.20notion.20.28not.20posting.20as.20an.20RFC.29.3A.20.60infix_func.60/near/232878391">said</a>:</p>
<blockquote>
<p>Who needs <code>k#keyword</code> when you have <code>keyword#</code></p>
</blockquote>
<p>Reminds me a little of <a href="https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/magic_hash.html">https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/magic_hash.html</a> .</p>



<a name="232985935"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/April%20Fools%20notion%20%28not%20posting%20as%20an%20RFC%29%3A%20%60infix_func%60/near/232985935" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/April.20Fools.20notion.20(not.20posting.20as.20an.20RFC).3A.20.60infix_func.60.html#232985935">(Apr 03 2021 at 06:37)</a>:</h4>
<p>This currently compiles on nightly:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#![feature(fn_traits)]</span><span class="w"></span>
<span class="cp">#![feature(unboxed_closures)]</span><span class="w"></span>

<span class="k">trait</span><span class="w"> </span><span class="n">Apply</span>: <span class="nb">Sized</span> <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">apply</span><span class="o">&lt;</span><span class="n">F</span>: <span class="nb">FnOnce</span><span class="o">&lt;</span><span class="bp">Self</span><span class="o">&gt;&gt;</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">f</span>: <span class="nc">F</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="o">&lt;</span><span class="n">F</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nb">FnOnce</span><span class="o">&lt;</span><span class="bp">Self</span><span class="o">&gt;&gt;</span>::<span class="n">Output</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">f</span><span class="p">.</span><span class="n">call_once</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="n">A</span><span class="p">,</span><span class="w"> </span><span class="n">B</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Apply</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="n">A</span><span class="p">,</span><span class="w"> </span><span class="n">B</span><span class="p">)</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">add</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">std</span>::<span class="n">ops</span>::<span class="n">Add</span>::<span class="n">add</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">v</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">).</span><span class="n">apply</span><span class="p">(</span><span class="n">add</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="fm">dbg!</span><span class="p">(</span><span class="n">v</span><span class="p">);</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="232989303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/April%20Fools%20notion%20%28not%20posting%20as%20an%20RFC%29%3A%20%60infix_func%60/near/232989303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/April.20Fools.20notion.20(not.20posting.20as.20an.20RFC).3A.20.60infix_func.60.html#232989303">(Apr 03 2021 at 07:46)</a>:</h4>
<p>oh yeah, rewrite all your arithmetic in RPN with this one weird trick</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>